package com.ruoyi.system.domain;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

public class CodeTableBo implements Serializable {
    private static final long serialVersionUID = -9016581476079217937L;
    /** 编码 */
    private String value;
    /** 码值 */
    private String label;
    /**行政区划层级*/
    private String areaLevel;
    /** 子类 */
    private List<CodeTableBo> children;
    /** 是否有子项*/
    private Boolean isLeaf;

    public String getAreaLevel() {
        return areaLevel;
    }

    public void setAreaLevel(String areaLevel) {
        this.areaLevel = areaLevel;
    }

    public String getValue() {
        return value;
    }

    public void setValue(String value) {
        this.value = value;
    }

    public String getLabel() {
        return label;
    }

    public void setLabel(String label) {
        this.label = label;
    }

    public List<CodeTableBo> getChildren(){
        return this.children;
    }

    public void setChildren(List<CodeTableBo> children) {
        this.children = children;
    }

    public Boolean getIsLeaf() {
        if(AreaConstant.LEVEL_THREE.equals(this.areaLevel)){
            return true;
        }else if(AreaConstant.LEVEL_TWO.equals(this.areaLevel)){
            if(this.value.startsWith(AreaConstant.BEI_JING)||this.value.startsWith(AreaConstant.TIAN_JIN)||
                    this.value.startsWith(AreaConstant.SHANG_HAI)||this.value.startsWith(AreaConstant.CHONG_QING)){
                return true;
            }
        }
        return false;
    }

    public void setIsLeaf(Boolean leaf) {
        isLeaf = leaf;
    }
}
